<script src="<?php echo base_url()?>/public/assets/js/laydate/laydate.js" type="text/javascript"></script>
<div class="row">
	<div class="col-sm-12">
		<div>
    		<a href="/admin/nursery/?per_page=<?php if(!empty($_REQUEST['per_page']))echo $_REQUEST['per_page']?>" class="btn btn-info_01 float_right btn_search">返回</a>
    	</div>
		<div class="space"></div>
        <form action="/admin/nursery/add" method="post" onsubmit="return yanzheng()">
		<input type="hidden" value="update" name="form_submit" />
		<input type="hidden" value="" name="id" />
		<table width="100%" class="table table-striped table-bordered table-hover" widtd="100%">
			<tr>
			    <td width="15%" height="30" widtd="15%">园所名称：</td>
				<td width="85%" height="30" align="left" widtd="85%">
				<input type="text" value="" name="title"/></td>
			</tr>
			<tr>
			  <td height="30">地区：</td>
			  <td height="30" align="left">
			  <select name="area_id" onchange = 'Getcity(value,"city_id")'>
			  	
			  </select>
			  </td>
		  </tr>
			<tr>
              <td height="30">市区：</td>
			  <td height="30" align="left">
			  <select name="city_id">
              </select>
               </td>
		  </tr>
			<tr>
			  <td height="30">客服电话：</td>
			  <td height="30" align="left"><input type="text" value="" name="telephone"/></td>
		  </tr>
			<tr>
			  <td height="30">详情地址：</td>
			  <td height="30" align="left"><textarea name="address" style="width:400px"></textarea></td>
		  </tr>
			<tr>
			  <td height="30">服务范围说明：</td>
			  <td height="30" align="left"><textarea name="explain" style="width:400px"></textarea></td>
		  </tr>
			<tr>
			  <td height="30">是否允许登陆：</td>
			  <td height="30" align="left"><select name="is_allow_login">
                <option value="1">允许</option>
                <option value="0">不允许</option>
              </select></td>
		  </tr>
			<tr>
			  <td height="30">是否支持划课：</td>
			  <td height="30" align="left"><select name="is_allow_huake" >
                <option value="1">支持</option>
                <option value="0">不支持</option>
              </select></td>
		  </tr>
			<tr>
			  <td height="30" colspan="2"><div align="center"><input type="submit" value="提交" /></div></td>
		  </tr>
	  </table>
	  </form>
	</div>
</div>
<script>
function yanzheng(){ 
	if(!$("[name='title']").val()){ 
	    alert('请输入名称！'); 
	    return false; 
	}
	if(!$("[name='address']").val()){ 
	    alert('请输入地址！'); 
	    return false; 
	}
	if(!$("[name='explain']").val()){ 
	    alert('请输入服务范围说明！'); 
	    return false; 
	}
	if(!$("[name='telephone']").val()){ 
	    alert('请输入客服电话！'); 
	    return false; 
	}	
	if(!confirm('确定要修改吗？')){
		return false;
	}
}
window.onload=function (){
	Getarea('area_id');
	var area_id = $("[name='area_id']").val();
	Getcity(area_id,'city_id');
}
/**
 * 获取地区
 */
function Getarea(name){
	//var id = $(object).val();
	$.ajax({
	    type : "get", 
	    async:false, 
	    url : "/admin/nursery/Getarea", 
	    dataType : "json", 
	    success : function(data){
		    if(data['code'] == 10){
			    var list = data['list'];
			    var content = '';
			    for(var i=0;i<list.length;i++){
				    content += '<option value="'+list[i]['id']+'">'+list[i]['title']+'</option>';
				}
			    $("[name='"+name+"']").html(content);
			}else{
				alert(data['msg']);
			}
	    }, 
	    error:function(){
	        alert('fail'); 
	    } 
	});
}
/**
 * 获取市区
 */
function Getcity(area_id,name){
	$.ajax({
	    type : "get", 
	    async:false, 
	    url : "/admin/nursery/Getcity?area_id="+area_id, 
	    dataType : "json", 
	    success : function(data){
		    if(data['code'] == 10){
			    var list = data['list'];
			    var content = '';
			    for(var i=0;i<list.length;i++){
				    content += '<option value="'+list[i]['id']+'">'+list[i]['title']+'</option>';
				}
			    $("[name='"+name+"']").html(content);
			}else{
				alert(data['msg']);
			}
	    }, 
	    error:function(){
	        alert('fail'); 
	    } 
	});
}
</script>
<!--content-->